package com.chixing.controller;


import com.chixing.service.ICouponService;
import com.chixing.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author smith
 * @since 2025-09-22
 */
@CrossOrigin
@RestController
@RequestMapping("/coupon")
public class CouponController {
    @Autowired
    private ICouponService couponService;

    @GetMapping("{id}")
    public Result getById(@PathVariable("id") Integer id){
        return couponService.getById(id);
    }

    //查询优惠券+用户是否可以领取
    @GetMapping("/status/{status}")
    public Result getStatusAll(@PathVariable("status") Integer couponStatus){
        Integer userId = 1;
        return couponService.getByStatus(userId,couponStatus);
    }
    //查询所有优惠券
    @GetMapping
    public Result getAll(){
        return couponService.getAll();
    }
}
